package org.apache.struts2.plugin.json;

/**
 * Definition of all TOKEN for JSON language.
 * @author VERDOÏA Laurent <verdoialaurent@gmail.com>
 */
public enum Token {

    /** The null object */
    NULL(new byte[]{'n', 'u', 'l', 'l'}),
    /** The boolean value true */
    TRUE(new byte[]{'t', 'r', 'u', 'e'}),
    /** The boolean value false */
    FALSE(new byte[]{'f', 'a', 'l', 's', 'e'}),
    /** The comma separator */
    COMMA(new byte[]{','}),
    /** The objectassigment separator */
    OBJECT_ASSIGNEMENT(new byte[]{':'}),
    /** The start token for an object */
    OBJECT_START(new byte[]{'{'}),
    /** The stop token for an object */
    OBJECT_END(new byte[]{'}'}),
    /** The start token for an array */
    ARRAY_START(new byte[]{'['}),
    /** The stop token for an array */
    ARRAY_END(new byte[]{']'}),
    /** The start token for an string */
    STRING_START(new byte[]{'\"'}),
    /** The stop token for an string */
    STRING_END(new byte[]{'\"'}),
    CHAR_QUOTATION_MARK(new byte[]{'\\', '\"'}),
    CHAR_REVERSE_SOLIDUS(new byte[]{'\\', '\\'}),
    CHAR_SOLIDUS(new byte[]{'\\', '/'}),
    CHAR_BACKSPACE(new byte[]{'\\', 'b'}),
    CHAR_LINE_FEED(new byte[]{'\\', 'f'}),
    CHAR_NEW_LINE(new byte[]{'\\', 'n'}),
    CHAR_CARRIAGE_RETURN(new byte[]{'\\', 'r'}),
    CHAR_HORIZONTAL_TAB(new byte[]{'\\', 't'});
    private final byte[] bytes;

    /**
     * Creation of an Token.
     * @param bytes Bytes array of the token
     */
    Token(byte[] bytes) {
        this.bytes = bytes;
    }

    /**
     * Return the byte array representing the token.
     * @return Byte array of token
     */
    public byte[] getBytes() {
        return this.bytes;
    }
}
